<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;

class tupianController extends Controller
{
    public function getIndex()
    {
    	return view('homes.setting');
    }

    public function getDesign()
    {
    	return view('homes.design');
    }

    public function getZhaop(Request $request)
    {
    	$abc = DB::table('photos')->paginate(6);
    	return view('homes.zhaop',['res'=>$abc]);
    }

    public function postIndex(Request $request)
    {
    	$res = $request -> file('tupian');

    	if(!empty($res)){
    		$name = time().rand(1000,9999).'.'.$res->getClientOriginalExtension();
		   
	    	$res -> move('./uploads',$name);
	    	DB::table('photos')->insert(
			    ['uid' => 1, 'photo' => $name]
			);
    		$abc = DB::table('photos')->paginate(6);
	    	return view('homes.zhaop',['res'=>$abc]);
    	} else {
    		return back();
    	}
    	
    }
}
